package hu;

import java.util.*;

public class hu41 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        sc.nextLine();
        String[] weight = sc.nextLine().split(" ");
        String[] num = sc.nextLine().split(" ");
        int[] weights = new int[m];
        int[] nums = new int[m];
        for (int i = 0; i < m; i++) {
            weights[i] = Integer.parseInt(weight[i]);
            nums[i] = Integer.parseInt(num[i]);
        }
        Set<Integer> set = new HashSet<>();
        set.add(0);
        for (int i = 0; i < m; i++) {
            ArrayList<Integer> list = new ArrayList<>(set);
            for (int j = 1; j <= nums[i]; j++) {
                for (int k = 0; k < list.size(); k++) {
                    set.add(list.get(k) + weights[i] * j);
                }
            }
        }
        System.out.println(set.size());
    }

}
